package Service;

import Dao.StudentDao;
import model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class StudentService {
@Autowired
    StudentDao studentDao;
@Resource(name="list")
    List<Student> students;


    public double average(){

          double sum=0.0;
          double aver=0.0;
          students=studentDao.queryAll();
          for(Student stu:students){
              sum=sum+stu.getGrades();
          }
          aver=sum/students.size();
          return aver;
        }

    public void insertStudent(Student student) {
        studentDao.insertStudent(student);
    }

}